#ifndef _LED_H_
#define _LED_H_

#include "stm8s_gpio.h"
#include "config.h"

#define OFF GPIO_WriteLow   
#define ON GPIO_WriteHigh

enum//每个灯的定义
{
    LED1,
    LED2,
    LED3,
    LED4,
    BUTTON_LED,
    LED_TOTAL
};

enum
{
    LED_ZER,
    LED_ONE,
    LED_TWO,
    LED_THR,
    LED_FOU,
    /********以下为闪烁*********/
    LED_BUTTON,    
    LED_ONE_CHARGE,
    LED_TWO_CHARGE,
    LED_THR_CHARGE,
    LED_FOU_CHARGE,
};

typedef void (* f_onOff)(GPIO_TypeDef*, GPIO_Pin_TypeDef);
typedef void (* f_led)(f_onOff, unsigned char);
static void ledOnOff(f_onOff onOff, unsigned char ledNum);

typedef struct led_s
{
    GPIO_TypeDef* ledPort[LED_TOTAL];
    GPIO_Pin_TypeDef ledPin[LED_TOTAL];
    f_led controlLed;
    u8 status;
}led_t;

//外部接口
extern const led_t * const g_pLed;
void ledInit(void);
void updateLedStatus();
void setLedStatus(u8 status);

#endif
